Skip to content

Use a plain loop in taskforeach for a single worker - #627

Merged
leburgel merged 1 commit into
mainfrom
lb/taskforeach_serial
Nov 19, 2026
Merged

leburgel merged 1 commit into
mainfrom
lb/taskforeach_serial

Conversation

@leburgel

Copy link
Copy Markdown
Member

Split off from #626, as suggested there.

With a single worker, taskforeach still went through the atomic counter that balances the load between tasks, which costs an atomic increment per item. A single worker now calls foreach directly, for both the ntasks and the resources method.

This matters for single-threaded index manipulations and planar traces of tensors with many small subblocks, where taskforeach runs once per subblock or block. I did not benchmark this branch on its own. Within #626, where the per-subblock cost is otherwise small, adding this path took permute! of a tensor with 40736 subblocks of 4 entries from about 59 ns to 34 ns per subblock (one thread).

🤖 Generated with Claude Code

With one worker, `taskforeach` still went through the atomic counter that balances the load between tasks, at the cost of an atomic increment per item. A single worker now uses `foreach` directly.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@leburgel
leburgel requested a review from lkdvos November 18, 2026 13:27
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/auxiliary/auxiliary.jl 62.92% <100.00%> (-27.89%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leburgel
leburgel merged commit 86d33b5 into main Nov 19, 2026
32 of 35 checks passed
@leburgel
leburgel deleted the lb/taskforeach_serial branch November 19, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants